

var Admin = Class({
	initialize:function() {
	
	},

	start:function() {
		var floater = new Modal({height:'300px',content:''});
		
		j.request('admin:loadFrame', {}, function(obj) {
			$('window_content').innerHTML = obj;	
		});
	},
	
	selectModule:function(id) {
		j.request('admin:setModule',{module:id},function(obj) {
			$('admin_workspace').innerHTML = obj;
			obj = JSON.decode(obj);
			
			this.m = id;
			
			this[obj['class']];
			this[this.m] = new this[this.m]();
			this[this.m].load(obj.js);
		});
	}
	
	/*
	admin_submit_newuser_result:function(obj) {
		var text = obj.responseText;
		var result = text.substr(0,text.indexOf(":"));
		var reason = text.substr(text.indexOf(":") + 1);
	
		if(result == 'error') {
			switch(reason) {
				case 'exist':
					$('submit_newuser_result').innerHTML = 'user with this email adress still exists';
					break;
				// if user requested password
				case 'sent':
					$('submit_newuser_result').innerHTML = 'password was sent to your email address';
					break;
					
				default:
					// reset field classes
					var fields = $('register_inputs').getElementsByTagName('input');
					fields = $A(fields);
					fields.each(function(e,myindex) {
						$(e.id).className='';
					});
	
					// mark missing or error fields red
					var fields = reason.substr(1).split("&");
					fields.each(function(e,myindex) {
						$(e).className+='redborder';
					});
					
					$('submit_newuser_result').innerHTML = 'please fill out the red bordered field(s)';
					
					break;
			}
			
		} else if (result == "success") {
			// reset field classes
			var fields = $('register_inputs').getElementsByTagName('input');
			fields = $A(fields);
			fields.each(function(e,myindex) {
				$(e).value='';
				$(e.id).className='';
			});
			
			$('submit_newuser_result').innerHTML = 'user successfully created, please check your e-mail inbox';
		}
	}*/
});
